package com.demo.service.impl;

import com.demo.dao.ProjectDao;
import com.demo.dto.ProjectDto;
import com.demo.pojo.Project;
import com.demo.service.ProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @ClassName ProjectService
 * @Description TODO
 * @Author Windy
 * @Date 2022/9/7 16:56
 * @Version 1.0
 **/
@Service
public class ProjectServiceImpl implements ProjectService {
    @Autowired
    ProjectDao projectDao;
    @Override
    public List<Project> findOneAndMany() {
        List<Project> oneAndMany = projectDao.findOneAndMany();
        System.out.println(oneAndMany);
        return oneAndMany ;
    }

    @Override
    public List<ProjectDto> findAllDto() {
        return projectDao.findAllDto();
    }

    @Transactional
    @Override
    public boolean updateProject(Project project) {
        return projectDao.updateProject(project)>=0;
    }

    @Transactional
    @Override
    public boolean deleteProjectById(int pid) {
        return projectDao.deleteProjectById(pid)>=0;
    }

    @Transactional
    @Override
    public boolean insertProject(Project project) {
        return projectDao.insertProject(project)>=0;
    }

    @Override
    public Project findOneById(int pid) {
        return projectDao.findOneById(pid);
    }
}
